package com.ccom.user.sync;

import com.ccom.api.domain.SysLoginLog;
import com.ccom.api.domain.User;
import com.ccom.api.feign.SysLogFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author zjj
 * @date 2021/10/9 10:10
 * @description
 */
@Component
public class UserSync {
    @Autowired
    SysLogFeign sysLogFeign;

    @Async
    public void saveLoginLog(User user, String type, String status) {
        SysLoginLog sysLoginLog = new SysLoginLog()
                .setUserId(user.getId())
                .setUserName(user.getUserName())
                .setStatus(status)
                .setType(type)
                .setIpaddr("")
                .setAccessTime(new Date());
        sysLogFeign.saveLoginLog(sysLoginLog);
    }
}
